package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.Question;
import com.ruoyi.system.domain.QuestionBank;
import com.ruoyi.system.service.IQuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/bank")
public class QuestionBankController extends BaseController{
    @Autowired
    private IQuestionBankService questionBankService;

    /**
     * 查询题库列表,外加模糊查询
     */
   /* @PreAuthorize("@ss.hasPermi('system:bank:list')")*/
    @GetMapping("/list")
    public TableDataInfo list(QuestionBank questionBank)
    {
        //进行分页
        startPage();
        List<QuestionBank> list = questionBankService.selectQuestionBankList(questionBank);
        return getDataTable(list);
    }

    /**
     * 新增题库
     */
  /*  @PreAuthorize("@ss.hasPermi('system:bank:add')")
    @Log(title = "题库", businessType = BusinessType.INSERT)*/
    @PostMapping
    public AjaxResult add(@RequestBody QuestionBank questionBank)
    {
        return toAjax(questionBankService.insertQuestionBank(questionBank));
    }

    /**
     * 修改题库
     */
 /*   @PreAuthorize("@ss.hasPermi('system:bank:edit')")
    @Log(title = "题库", businessType = BusinessType.UPDATE)*/
    @PutMapping
    public AjaxResult edit(@RequestBody QuestionBank questionBank)
    {
        //响应结果返回
        return toAjax(questionBankService.updateBank(questionBank));
    }

    /**
     * 删除题库批量删除
     */
/*    @PreAuthorize("@ss.hasPermi('system:bank:remove')")
    @Log(title = "题库", businessType = BusinessType.DELETE)*/
    @DeleteMapping("/{bankIds}")
    public AjaxResult remove(@PathVariable Long[] bankIds)
    {
        return toAjax(questionBankService.deleteBankByIds(bankIds));
    }
}

